package com.hshit.downloader.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.hshit.downloader.fragment.BaseFragment;
import com.hshit.downloader.fragment.DownloadStatusFragment;
import com.hshit.downloader.fragment.LayoutTab;
import com.hshit.downloader.fragment.Mp3Fragment;
import com.hshit.downloader.utils.Constants;

public class ActionFragmentAdapter extends FragmentPagerAdapter {
	
	private final String[] TITLES = {Constants.TITLE_MP3, Constants.TITLE_DOWNLOAD};
	
	private LayoutTab mTabs[] = new LayoutTab[3];
	
    public ActionFragmentAdapter(FragmentManager fm) {
        super(fm);
    }
    
	@Override
	public CharSequence getPageTitle(int position) {
		return TITLES[position];
	}

	@Override
	public int getCount() {
		return TITLES.length;
	}

	@Override
	public Fragment getItem(int position) {
		if(position == BaseFragment.TAB_MP3) {
			mTabs[0] = Mp3Fragment.newInstance(position);
			return mTabs[0];
		} else {
			mTabs[1] = DownloadStatusFragment.newInstance(position);
			return mTabs[1];
		}
	}
	
	public LayoutTab getFragmentTab(int i) {
		return mTabs[i];
	}
	
}
